package com.gwnet.user.controller;


import com.gwnet.common.core.domain.ResponseResult;
import com.gwnet.common.satoken.utils.LoginHelper;
import com.gwnet.user.domain.CusUser;
import com.gwnet.user.service.CusUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author WangLiang
 * @since 2024-07-20
 */
@Slf4j
@RestController
@RequestMapping("/cusUser")
public class CusUserController {


    private final CusUserService cusUserService;

    public CusUserController(CusUserService cusUserService) {
        this.cusUserService = cusUserService;
    }

    /**
     * 根据用户ID，获取用户详情
     * @return
     */
    @PostMapping("/view")
    public ResponseResult<CusUser> view(){
//        boolean login = LoginHelper.isLogin();
//        log.info("《login》======status:{}",login);
        Long userId = LoginHelper.getLoginUser().getUserId();
        log.info("《login》======userId:{}",userId);
        CusUser user = cusUserService.getById(userId);
        // 密码置空
        user.setLoginPassword(null);
        return ResponseResult.success(user);
    }

}

